// app.js
import api from './utils/api'
App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    // wx.login({
    //   success: res => {
    //     // 发送 res.code 到后台换取 openId, sessionKey, unionId
    //   }
    // })
    this.denglu()
  },
  denglu:function(){
    var that = this;
    wx.login({
      success(res) {
        console.log(res)
        if (res.code) {
          api.getXcxOpenId({
            data: {
              code: res.code
            },
            success: function (res) {
              console.log(res.data.data)
              // that.globalData.openSession = res.data.data;
              // wx.setStorageSync('openSession', res.data.data)
            }
          })
        } else {
          wx.showModal({
            content: '网络状况不好，请稍候',
            showCancel: false
          })
          
        }
      }
    })
  },
  globalData: {
    userInfo: null
  }
})
